package demo.Controller;

import cn.springmix.core.exception.ServiceException;
import demo.dto.UserDto;
import demo.dto.UserVo;
import org.springframework.web.bind.annotation.*;

/**
 * @author xufeng
 * @description: 测试一下包装类 和全局异常
 * @date 2022-04-20 13:47
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @PostMapping("/hello")
    public String test(){
        return "hello";
    }

    @GetMapping("/serviceEx")
    public void serviceEx(){
        throw new ServiceException(200,"zzz");
    }

    /**
     * 测试对象参数 文档自动生成
     */
    @PostMapping("/param")
    public UserVo param(@RequestBody UserDto userDto){
        UserVo userVo = new UserVo();
        userVo.setUserId("zz");
        userVo.setUsername("张三");
        return userVo;
    }

}
